function addEvent(a, b, c) {
    if (a.addEventListener) {
        a.addEventListener(b, c, true);
        return true
    } else if (a.attachEvent) {
        var r = a.attachEvent("on" + b, c);
        return r
    } else {
        return false
    }
};
function removeEvent(a, b, c, d) {
    if (a.removeEventListener) {
        a.removeEventListener(b, c, d);
        return true
    } else if (a.detachEvent) {
        var r = a.detachEvent("on" + b, c);
        return r
    } else {
        alert("Handler could not be removed")
    }
};
function getViewportHeight() {
    if (window.innerHeight != window.undefined) return window.innerHeight;
    if (document.compatMode == 'CSS1Compat') return document.documentElement.clientHeight;
    if (document.body) return document.body.clientHeight;
    return window.undefined
};
function getViewportWidth() {
    if (window.innerWidth != window.undefined) return window.innerWidth;
    if (document.compatMode == 'CSS1Compat') return document.documentElement.clientWidth;
    if (document.body) return document.body.clientWidth;
    return window.undefined
};
var gPopupMask = null;
var gPopupContainer = null;
var gPopFrame = null;
var gReturnFunc;
var gPopupIsShown = false;
var gPopupTitle = null;
var gHideSelects = true;
var gHideObjects = true;
var gLoadingUrl = null;
var gTabIndexes = new Array();
var gTabbableTags = new Array("A", "BUTTON", "TEXTAREA", "INPUT", "IFRAME");
if (!document.all) {
    document.onkeypress = keyDownHandler
}
function initPopUp() {
    gPopupMask = document.getElementById("popupMask");
    gPopupContainer = document.getElementById("popupContainer");
    gPopFrame = document.getElementById("popupFrame");
    var a = parseInt(window.navigator.appVersion.charAt(0), 10);
    if (a <= 6 && window.navigator.userAgent.indexOf("MSIE") > -1) {
        gHideSelects = true
    }
};
addEvent(window, "load", initPopUp);
function renderPopWin() {
    gLoadingUrl = "loading.jsp";
    document.write("<div id=\"popupMask\" style=\"display: none;background-color:transparent;\"> </div>");
    document.write("<div id=\"popupContainer\" style=\"display: none;\">");
    document.write("<div id=\"popupInner\">");
    document.write("<div id=\"popupTitleBar\">");
    document.write("<div id=\"popupTitle\"></div>");
    document.write("<div id=\"popupControls\">");
    document.write("<img src=\"images/close.gif\" onclick=\"hidePopWin(false);\" />");
    document.write("</div>");
    document.write("</div>");
    document.write("<iframe src=\"loading.jsp\" style=\"width:100%;height:100%;background-color:transparent;\" scrolling=\"auto\" frameborder=\"0\" allowtransparency=\"true\" id=\"popupFrame\" name=\"popupFrame\" width=\"100%\" height=\"100%\"></iframe>");
    document.write("</div>");
    document.write("</div>")
};
function showPopWin(a, b, c, d) {
    gPopupIsShown = true;
    disableTabIndexes();
    gPopupMask.style.display = "block";
    gPopupContainer.style.display = "block";
    centerPopWin(b, c);
    var e = parseInt(document.getElementById("popupTitleBar").offsetHeight, 10);
    gPopupContainer.style.width = b + "px";
    gPopupContainer.style.height = (c + e) + "px";
    gPopFrame.style.width = parseInt(document.getElementById("popupTitleBar").offsetWidth, 10) + "px";
    gPopFrame.style.height = (c) + "px";
    gPopFrame.src = a;
    gReturnFunc = d;
    if (gHideSelects || gHideObjects) {
        hideSelectBoxes()
    }
    window.setTimeout("setPopTitle();", 249)
};
var gi = 0;
function centerPopWin(a, b) {
    if (gPopupIsShown == true) {
        if (a == null || isNaN(a)) {
            a = gPopupContainer.offsetWidth
        }
        if (b == null) {
            b = gPopupContainer.offsetHeight
        }
        var c = getViewportHeight();
        var d = getViewportWidth();
        var e = document.body;
        var t, l, w, h;
        if (document.documentElement && document.documentElement.scrollTop) {
            t = document.documentElement.scrollTop;
            l = document.documentElement.scrollLeft;
            w = document.documentElement.scrollWidth;
            h = document.documentElement.scrollHeight
        } else if (document.body) {
            t = document.body.scrollTop;
            l = document.body.scrollLeft;
            w = document.body.scrollWidth;
            h = document.body.scrollHeight
        }
        var f = parseInt(t, 10);
        var g = parseInt(l, 10);
        gPopupMask.style.height = c + "px";
        gPopupMask.style.width = d + "px";
        gPopupMask.style.top = f + "px";
        gPopupMask.style.left = g + "px";
        var i = parseInt(document.getElementById("popupTitleBar").offsetHeight, 10);
        gPopupContainer.style.top = (f + ((c - (b + i)) / 2)) + "px";
        gPopupContainer.style.left = (g + ((d - a) / 2)) + "px"
    }
};
addEvent(window, "resize", centerPopWin);
window.onscroll = centerPopWin;
function hidePopWin(a) {
    gPopupIsShown = false;
    restoreTabIndexes();
    if (gPopupMask == null) {
        return
    }
    gPopupMask.style.display = "none";
    gPopupContainer.style.display = "none";
    if (a == true && gReturnFunc != null) {
        gReturnFunc(window.frames["popupFrame"].returnVal)
    }
    gPopFrame.src = gLoadingUrl;
    if (gHideSelects || gHideObjects) {
        displaySelectBoxes()
    }
};
function setPopTitle() {
    document.getElementById("popupTitle").innerHTML = window.frames["popupFrame"].document.title;
    window.setTimeout("setPopTitle();", 999);
    return;
    if (window.frames["popupFrame"].document.title == null || window.frames["popupFrame"].document.title == gPopupTitle) {
        window.setTimeout("setPopTitle();", 99)
    } else {
        document.getElementById("popupTitle").innerHTML = window.frames["popupFrame"].document.title
    }
};
function keyDownHandler(e) {
    if (gPopupIsShown && e.keyCode == 9) return false
};
function disableTabIndexes() {
    if (document.all) {
        var i = 0;
        for (var j = 0; j < gTabbableTags.length; j++) {
            var a = document.getElementsByTagName(gTabbableTags[j]);
            for (var k = 0; k < a.length; k++) {
                gTabIndexes[i] = a[k].tabIndex;
                a[k].tabIndex = "-1";
                i++
            }
        }
    }
};
function restoreTabIndexes() {
    if (document.all) {
        var i = 0;
        for (var j = 0; j < gTabbableTags.length; j++) {
            var a = document.getElementsByTagName(gTabbableTags[j]);
            for (var k = 0; k < a.length; k++) {
                a[k].tabIndex = gTabIndexes[i];
                a[k].tabEnabled = true;
                i++
            }
        }
    }
};
function hideSelectBoxes() {
    for (var i = 0; i < document.forms.length; i++) {
        for (var e = 0; e < document.forms[i].length; e++) {
            if ((gHideSelects && document.forms[i].elements[e].tagName == "SELECT") || (gHideObjects && document.forms[i].elements[e].tagName == "OBJECT")) {
                document.forms[i].elements[e].style.display = "none"
            }
        }
    }
};
function displaySelectBoxes() {
    for (var i = 0; i < document.forms.length; i++) {
        for (var e = 0; e < document.forms[i].length; e++) {
            if ((gHideSelects && document.forms[i].elements[e].tagName == "SELECT") || (gHideObjects && document.forms[i].elements[e].tagName == "OBJECT")) {
                document.forms[i].elements[e].style.display = ""
            }
        }
    }
};